package com.north.light.androidutils.shareele;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityOptionsCompat;

import com.north.light.androidutils.R;

/**
 * 共享元素
 */
public class ShareElementActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share_element);

        ImageView ivImg = findViewById(R.id.ivLogo);
        ivImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ivImg.setTransitionName("image");
                Intent intent = new Intent(ShareElementActivity.this,
                        ShareEleSecondActivity.class);
                Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                        ShareElementActivity.this, ivImg, "image").toBundle();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent, bundle);
            }
        });
    }
}